fix(security): bind repository scanners to exact PR head - #799
fix(security): bind repository scanners to exact PR head#799seonghobae wants to merge 18 commits into
Conversation
📝 WalkthroughWalkthroughPR의 실제 head 저장소와 SHA를 보안 스캔 입력과 SARIF 식별자에 고정했습니다. Dependency Review API는 HTTP 200에서만 성공하며, 관련 계약 테스트와 quality CI를 추가했습니다. 운영 계약과 rollback 절차도 문서화했습니다. ChangesExact-head 보안 스캔
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PullRequest
participant GitHubActions
participant DependencyReviewAPI
participant Trivy
participant Scorecard
participant SARIFUpload
PullRequest->>GitHubActions: head repository와 head SHA 제공
GitHubActions->>DependencyReviewAPI: base SHA와 head SHA 비교 요청
DependencyReviewAPI-->>GitHubActions: HTTP 200 또는 실패 상태 반환
GitHubActions->>Trivy: head repository와 head SHA checkout
GitHubActions->>Scorecard: head repository와 head SHA checkout
Trivy->>SARIFUpload: head ref와 head SHA를 포함한 SARIF 업로드
Scorecard->>SARIFUpload: head ref와 head SHA를 포함한 SARIF 업로드
Possibly related issues
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@opencode-agent Extend this exact-current-head security-scan repair test-first to address #810, and do nothing if PR #799 branch head is no longer A downstream exact-head canary exposed a valid organization-level fail-open defect in the same workflow. Use two auditable commits in order:
Update doctoring so its claimed fail-closed behavior matches production and include current APA 7 primary references to GitHub Dependency Review, Dependency Graph, and Dependency Review REST API. Add one concise Do not change After GREEN, run the focused dependency-free contract and the complete central Python test/100% statement+branch coverage/public-docstring/compile contract available on the branch. Then leave PR #799 unmerged and request fresh exact-GREEN CodeRabbit/OpenCode/Noema review plus every required security workflow; do not claim queued, absent, skipped, predecessor-head, or synthetic-merge evidence as current-head success. Report immutable RED and GREEN SHAs in this PR conversation. |
|
@opencode-agent Extend this existing security-scan repair test-first on exact current head Fresh downstream evidence from Use the existing PR #799 rather than creating a competing PR because it already owns Required RED → GREEN extension:
Modify only the already-owned PR #799 security-scan workflow/contract/helper/documentation/CHANGELOG surface needed for this repair. Do not add any repository-write, OIDC, branch/ref publication, PR creation/merge, release/package/signing authority, temporary write-capable workflow, self-modifying workflow, model-modified-tree publication, or conflict strategy. Do not merge or mark Ready. After GREEN, require fresh exact-current-head central quality/security/review evidence and preserve independent non-author approval and branch protection as mandatory gates. |
|
@opencode-agent @cwl-noema-review @coderabbitai review Review-only request for exact current head |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
requested_head='aee317b3ecbfaad7cdb3898e603dfe5e69b8f7ae'
protected_main='f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae'
printf '%s\n' '== Current commit =='
git rev-parse HEAD
printf '%s\n' '== Requested commit exists =='
git rev-parse "${requested_head}^{commit}"
printf '%s\n' '== Requested protected commit exists =='
git rev-parse "${protected_main}^{commit}"
printf '%s\n' '== Merge base =='
git merge-base "$protected_main" "$requested_head"
printf '%s\n' '== Changed files =='
git diff --name-status "$protected_main" "$requested_head"
printf '%s\n' '== Workflow outline =='
ast-grep outline .github/workflows/security-scan.yml --items all || true
printf '%s\n' '== Focused test candidates =='
fd -t f 'security.*scan.*exact.*head|exact.*head.*security.*scan|security.*scan.*dependency.*review' tests . 2>/dev/null || true
printf '%s\n' '== Workflow security-sensitive lines =='
rg -n -C 4 --glob '.github/workflows/security-scan.yml' \
'actions/checkout|dependency-review-action|upload-sarif|head\.repo|head\.sha|refs/pull|persist-credentials|permissions:|security-events|contents:|pull-requests:|trivy|scorecard|severity|fail-on-severity' .Length of output: 2385 🏁 Script executed: #!/bin/bash
set -euo pipefail
base='f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae'
head='aee317b3ecbfaad7cdb3898e603dfe5e69b8f7ae'
for file in \
.github/workflows/security-scan.yml \
.github/workflows/security-scan-exact-head-quality-ci.yml \
tests/test_security_scan_exact_head.py \
tests/test_security_scan_sarif_exact_head.py \
docs/doctoring/security-scan-exact-head.md \
CHANGELOG.md
do
printf '\n== %s ==\n' "$file"
nl -ba "$file"
done
printf '\n== Complete diff ==\n'
git diff --no-ext-diff --unified=80 "$base" "$head" -- \
.github/workflows/security-scan.yml \
.github/workflows/security-scan-exact-head-quality-ci.yml \
tests/test_security_scan_exact_head.py \
tests/test_security_scan_sarif_exact_head.py \
docs/doctoring/security-scan-exact-head.md \
CHANGELOG.mdLength of output: 1191 🏁 Script executed: #!/bin/bash
set -u
base='f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae'
head='aee317b3ecbfaad7cdb3898e603dfe5e69b8f7ae'
print_file() {
file="$1"
printf '\n== %s ==\n' "$file"
if command -v awk >/dev/null 2>&1; then
awk '{ printf "%6d %s\n", NR, $0 }' "$file"
else
cat "$file"
fi
}
for file in \
.github/workflows/security-scan.yml \
.github/workflows/security-scan-exact-head-quality-ci.yml \
tests/test_security_scan_exact_head.py \
tests/test_security_scan_sarif_exact_head.py \
docs/doctoring/security-scan-exact-head.md \
CHANGELOG.md
do
print_file "$file"
done
printf '\n== Complete scoped diff ==\n'
git diff --no-ext-diff --unified=80 "$base" "$head" -- \
.github/workflows/security-scan.yml \
.github/workflows/security-scan-exact-head-quality-ci.yml \
tests/test_security_scan_exact_head.py \
tests/test_security_scan_sarif_exact_head.py \
docs/doctoring/security-scan-exact-head.md \
CHANGELOG.md || trueLength of output: 65118 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/.github'
pr='799'
printf '%s\n' '== Pull request identity =='
gh pr view "$pr" --repo "$repo" \
--json number,headRefOid,baseRefOid,isDraft,mergeStateStatus \
--jq '{number, headRefOid, baseRefOid, isDraft, mergeStateStatus}'
printf '%s\n' '== Check runs for the requested head =='
gh api "repos/${repo}/commits/aee317b3ecbfaad7cdb3898e603dfe5e69b8f7ae/check-runs?per_page=100" \
--jq '.check_runs[] | {name, status, conclusion, details_url}'
printf '%s\n' '== Workflow-run conclusions for the requested head =='
gh run list --repo "$repo" \
--commit aee317b3ecbfaad7cdb3898e603dfe5e69b8f7ae \
--limit 100 \
--json databaseId,name,status,conclusion,event,headSha,url \
--jq '.[] | {databaseId, name, status, conclusion, event, headSha, url}'Length of output: 23567
Finding — P1: dependency-review can succeed without dependency-review evidence In Treat unavailable support as unavailable security evidence. Fail the job with a concise error that identifies the repository and exact base/head. Do not print the response body. This behavior is relevant to the reported EgressWeave public-repository The remaining requested controls are present:
I cannot approve while the dependency-review fail-open path remains.
|
|
Review-only request for exact current head |
|
@cwl-noema-review Independently review exact current head |
|
@coderabbitai review Final read-only exact-head review for |
Rate Limit Exceeded
|
|
@opencode-agent review Review exact head |
|
@cwl-noema-review review Independently review exact head |
aee317b to
323c07b
Compare
|
@opencode-agent Exact-head correction for #810: extend only current PR #799 head Preserve the existing exact-PR-head checkout/SARIF binding repair. Add the dependency-review availability repair test-first in two auditable commits:
Keep exact Do not add or use a temporary/self-modifying/write-capable workflow, |
|
Review-only exact-head request for |
|
@cwl-noema-review Independently review exact head |
|
@coderabbitai review Final read-only review for exact head |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='ContextualWisdomLab/.github'
pr='799'
head='323c07b794d11f82c04db91544bc3a3f5cf5ad5c'
printf '%s\n' '== Pull request identity =='
gh pr view "$pr" --repo "$repo" \
--json number,headRefOid,baseRefOid,isDraft,mergeStateStatus \
--jq '{number, headRefOid, baseRefOid, isDraft, mergeStateStatus}'
printf '%s\n' '== Local checked-out commit =='
git rev-parse HEAD
printf '%s\n' '== Requested commit =='
git rev-parse "${head}^{commit}"
printf '%s\n' '== Changed files against PR base =='
base="$(gh pr view "$pr" --repo "$repo" --json baseRefOid --jq .baseRefOid)"
git diff --name-status "$base" "$head"
printf '%s\n' '== Workflow structure =='
ast-grep outline .github/workflows/security-scan.yml --items all || true
printf '%s\n' '== Exact-head and policy-sensitive workflow lines =='
rg -n -C 5 \
'actions/checkout|dependency-review-action|upload-sarif|head\.repo\.full_name|head\.sha|refs/pull|persist-credentials|permissions:|security-events:|contents:|pull-requests:|trivy|scorecard|severity|fail-on-severity|BASE_SHA|HEAD_SHA|supported=' \
.github/workflows/security-scan.yml
printf '%s\n' '== Focused contract test candidates =='
fd -t f 'test_security_scan_exact_head.py|test_security_scan_sarif_exact_head.py|test_security_scan_dependency_review.py' tests 2>/dev/null \
| sort \
| xargs -r -n1 sh -c 'echo "== $0 =="; sed -n "1,260p" "$0"'
printf '%s\n' '== Scoped documentation and changelog changes =='
git diff --no-ext-diff --unified=50 "$base" "$head" -- \
.github/workflows/security-scan.yml \
.github/workflows/security-scan-exact-head-quality-ci.yml \
tests/test_security_scan_exact_head.py \
tests/test_security_scan_sarif_exact_head.py \
tests/test_security_scan_dependency_review.py \
docs/doctoring/security-scan-exact-head.md \
CHANGELOG.md
printf '%s\n' '== Check runs for requested head =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
--jq '.check_runs[] | {name, status, conclusion, details_url}'
printf '%s\n' '== Workflow runs for requested head =='
gh run list --repo "$repo" --commit "$head" --limit 100 \
--json databaseId,name,status,conclusion,event,headSha,url \
--jq '.[] | {databaseId,name,status,conclusion,event,headSha,url}'Length of output: 58020
Finding — P1: dependency-review can pass without dependency-review evidence In The exact head still contains the EgressWeave fail-open path from the prior review. Treat The requested exact-head controls are present:
I cannot approve while the dependency-review fail-open path remains. You are interacting with an AI system. |
|
Supersede the immediately preceding review-only request at issue comment Current-head inspection still shows After a new exact GREEN head implements #810, request fresh CodeRabbit/OpenCode/Noema review and every required quality/security/supply-chain workflow against that new SHA only. Predecessor-head success and this superseded review request are stale evidence. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/security-scan.yml:
- Around line 278-285: Update the dependency-review probe curl command in
.github/workflows/security-scan.yml lines 278-285 to include both connection and
total execution time limits, while preserving the existing HTTP-status handling
and failure behavior after timeout. Update
tests/test_security_scan_exact_head.py lines 66-73 to assert that the probe
command contains both --connect-timeout and --max-time.
In `@docs/doctoring/security-scan-exact-head.md`:
- Around line 49-50: Update the response-body validation in
tests/test_security_scan_exact_head.py to require curl usage that discards the
body, such as -o /dev/null or an equivalent sink, rather than only rejecting cat
"$response_file". Preserve the existing documentation describing this
verification.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 719ba3c6-27f6-402e-8ce1-29a912f4dbe9
📒 Files selected for processing (7)
.github/workflows/security-scan-exact-head-quality-ci.yml.github/workflows/security-scan.ymlCHANGELOG.mdREADME.mddocs/doctoring/security-scan-exact-head.mdtests/test_security_scan_exact_head.pytests/test_security_scan_sarif_exact_head.py
|
@opencode-agent Address both current-head CodeRabbit threads on this branch with the minimal TDD change only:
|
|
@cwl-noema-review @opencode-agent Review-only request for live exact head |
|
@opencode-agent Fix the exact-current-head failed contract on Exact-head quality run Use the existing immutable RED contract. Modify only Then rerun the exact-head contract and complete required checks. Do not merge, rebase, retarget, or alter review identities. |
|
@opencode-agent Apply the bounded GREEN workflow repair to exact current head The exact test-only RED commit is complete. Security Scan Exact-Head Quality CI run Modify only In the curl -sS -o /dev/null -w '%{http_code}' \with: curl -sS --connect-timeout 10 --max-time 30 -o /dev/null -w '%{http_code}' \Preserve the existing authorization headers, exact base/head URL, discarded response body, |
|
@opencode-agent address Current head git apply --check docs/superpowers/patches/2026-08-07-dependency-review-timeouts.patch
git apply docs/superpowers/patches/2026-08-07-dependency-review-timeouts.patch
rm docs/superpowers/patches/2026-08-07-dependency-review-timeouts.patch
python -m pytest tests/test_security_scan_exact_head.py tests/test_security_scan_sarif_exact_head.py -q
python -m coverage erase
python -m coverage run -m pytest tests -q
python -m coverage report
python -m compileall -q tests
git diff --checkThe probe must retain |
|
@opencode-agent The exact head is now On this exact head, perform both operations in one commit:
curl -sS -o /dev/null -w '%{http_code}' \with exactly curl -sS --connect-timeout 10 --max-time 30 -o /dev/null -w '%{http_code}' \Do not line-wrap that curl command. Preserve every other workflow byte and path. The immutable RED test commit |
|
@coderabbitai autofix |
Rate Limit Exceeded
|
|
Exact current head The exact desired minimal workflow diff is already staged in |
Dismissed as stale-head evidence only. This review is anchored to dfa28786a6d57628b26ddbf1f466cbf9084e725d and workflow run 31146397750; the PR now has exact head e7690e359791353fb5547e1b4a4d1e4272f78cc3. The timeout/body-discard RED contracts were implemented, the temporary patch artifact was removed, and Security Scan Exact-Head Quality CI run 31148401381 succeeded on the new exact head. This dismissal does not approve the current tree: fresh current-head automated review, all remaining checks, independent approval, branch protection, and repository policy are still required.
|
@opencode-agent Perform a read-only exact-head review of Verify the literal pull-request head repository/SHA checkout for dependency review, Trivy, and Scorecard; exact-head SARIF attribution; only-HTTP-200 continuation for dependency-review support; @coderabbitai review Review only exact head |
Rate Limit Exceeded
|
|
@opencode-agent @cwl-noema-review Review-only request for exact current head |
|
@coderabbitai review Review only exact current head |
Rate Limit Exceeded
|
|
Exact-current-head read-only review request after the bounded dependency-review timeout repair. Head: @coderabbitai review Review only this exact head. Revalidate exact-head checkout/SARIF identity, the only-HTTP-200 dependency-review gate, 10-second connection and 30-second total limits, response-body discard, fail-closed timeout/transport handling, documentation, and exact-head check evidence. Do not mutate the branch, approve from the author identity, merge, alter reviewer credentials, or weaken the hard gate. |
|
@opencode-agent @cwl-noema-review Read-only exact-head review request for |
Rate Limit Exceeded
|
|
Exact-current-head read-only review request after bounded dependency-review availability and response-body suppression repairs. Head: @coderabbitai review Review only exact head |
|
Your plan includes PR reviews subject to rate limits. More reviews will be available in 29 minutes. |
|
@opencode-agent Perform a read-only exact-head review of PR #799 at Inspect the complete seven-file diff and independently verify: exact pull-request head repository/SHA checkouts; exact base/head dependency comparison; HTTP 200 as the sole successful support result; 10-second connect and 30-second total probe deadlines; discarded response body and non-leaking diagnostics; immutable action pins; read-only/fork-compatible permissions; exact-head SARIF attribution; no fail-open or dependency-neutral substitute; quality-contract RED/GREEN evidence; documentation and CHANGELOG alignment; all exact-current-head checks and zero unresolved valid threads. Anchor any formal review to this PR and exact head. Dismissed or predecessor-head reviews are historical only. Do not merge, release, publish, or bypass independent non-author approval. |
Purpose
Restore exact-head security evidence for organization-required repository scanners and fail closed when dependency-review evidence is unavailable. DiskSage PR #137 exposed synthetic-merge scanner input; the public EgressWeave canary later exposed a separate fail-open dependency-review support path where HTTP 403 skipped the hard action while the aggregate Security Scan remained green.
Implemented boundary
refs/pull/<number>/headand the same exact head SHA.000, empty/malformed status, and every unexpected outcome fail closed.actions/dependency-review-actionhard gate. Nosupported=falsegreen-skip path remains.Test-first evidence
Exact-head scanner identity
3a1f49a6d5e07b2a3aedd42627579d3e4d3213ce: the focused quality contract failed because affected jobs still relied on the synthetic merge checkout.aee317b3ecbfaad7cdb3898e603dfe5e69b8f7ae: checkout and SARIF identity contracts passed.Dependency-review availability and bounded execution
2d1603f1c307be83a12d8b2f847d6a91b1ce97b: exposed the prior HTTP 403/404supported=falseskip path.7c0b6f9ffb7bc1c6364df3101879191648302210: accepts only HTTP 200, discards the response body, and fails closed otherwise.31148072206then failed specifically because the required connection and total timeout arguments were absent.3ccb6167ba4a598319d8221a3e40298d6680848badds--connect-timeout 10and--max-time 30without weakening status handling.e7690e359791353fb5547e1b4a4d1e4272f78cc3removes the temporary staged patch artifact from the durable product diff.Exact-head verification
Exact current head:
e7690e359791353fb5547e1b4a4d1e4272f78cc3.Successful on this exact head:
31148401381;31148401392and newer same-head run31148588721;31148401428;31148401387;31148401543and newer same-head run31148588750;31148401380and newer same-head run31148588724;31148403002and newer same-head run31148589040;31148401994and newer same-head run31148588694;31148401417and newer same-head run31148588756; andThe CodeRabbit timeout and response-body findings are implemented and resolved. The existing OpenCode request-changes review is anchored to predecessor head
dfa28786a6d57628b26ddbf1f466cbf9084e725dand is not current-head evidence.Operator contract
For a public GitHub.com repository, an unavailable dependency-review endpoint is a repository/organization configuration or capability problem until proven otherwise. Correct dependency graph, GitHub security capability, organization policy, or token access, then rerun. Do not manufacture a green required check by weakening the hard gate. Any private/internal repository exception must be separately governed by organization policy and entitlement evidence rather than inferred from a failed support probe.
docs/doctoring/security-scan-exact-head.mdrecords exact-head authorization, SARIF identity, dependency-review fail-closed behavior, bounded execution, rollback, operator remediation, and APA 7 primary-source references.CHANGELOG.mdrecords the repair.Merge gate
Merge only after completed exact-current-head automated review, a qualifying independent non-author formal approval, zero unresolved valid findings, branch protection, and repository policy succeed without bypass. Queued, skipped, failed, predecessor-head, synthetic-merge, status-only, or author-only evidence is not acceptance evidence.